package com.cgsrp.cgsrp_baby.controller;

import com.cgsrp.cgsrp_baby.domain.ImportThings;
import com.cgsrp.cgsrp_baby.service.ImportThingsService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("thing")
public class BabyImportThingController {
    @Autowired
    private ImportThingsService thingsService;

    @GetMapping("list")
    public PageInfo<ImportThings> list (
            @RequestParam()int[] babyIds,
            @RequestParam(defaultValue = "1")Integer curPage,
            @RequestParam(defaultValue = "3")Integer pageSize
    ){
        return thingsService.list(babyIds,curPage,pageSize);
    }

    @PostMapping("add")
    public String add(ImportThings importThings){
        return thingsService.add(importThings);
    }

    @PostMapping("del")
    public boolean del(int id){
        return thingsService.del(id);
    }
}
